#include <bits/stdc++.h>
using namespace std;
#define ll int
#define x first
#define y second
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > > q;
bool duel[100005];
queue<pair<ll,ll> > tmp;

int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ll n,a,ans;
    cin>>n;
    ans=n;
    for(ll i=0;i<n;i++){
        cin>>a;
        q.push(make_pair(a,i));
    }
    while(1){
        bool flag=1;
        pair<ll,ll> i,j;
        j.x=q.top().x;
        i = q.top();
        q.pop();
        while((j.x<=i.x||duel[j.y])&&!q.empty())
        {
            j = q.top();
            q.pop();
            tmp.push(j);
        }
        ans--;
        if(!q.empty()){
            duel[j.y]=1;
            while(!tmp.empty()){
                pair<ll,ll> k=tmp.front();
                q.push(k);
                tmp.pop();
            }
        }
        else{
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}
